<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
	<title>发表留言</title>
</head>
<body>
     <?php 
     session_start();
    require_once("./system/dbConn.php");
    connect();
    //收集表单元素的值
   
    $vid=$_POST["vid"];
    $content=$_POST["content"];
    $username=$_SESSION["username"];//当用户登成功，把用户名写入变量中

    //根据username查询uid
    $sql="select uid from users where uname='$username'";
    $result=mysql_query($sql);
    $row=mysql_fetch_assoc($result);
    $uid=$row["uid"];

    //添加留言信息
    $sql1="insert into comments values (null,'$content',now(),$uid,$vid)";
    $result1=mysql_query($sql1);
    if ($result1) {
    	echo "留言添加成功，3秒后返回";
    	 header("refresh:3;url='show.php?vid=$vid'");

    }
    else{
    	echo "留言添加失败";
    }

    ?>
</body>
</html>